<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ include file="header.jsp"%>
<script type="text/javascript" src="<%=path%>/scripts/My97DatePicker/WdatePicker.js"></script>

<div id="searchCondition2" class="tabCont phl ptm">
	<div id="district" class="searchCondition" field="date">
		<span class="title">时间：</span> 
		<a class="noDistrict fcbl" dataType="0" href="#">不限</a>
		<div class="districtCodition">
			<a class="fcbl " dataType="1" data='2013-06-02' href="#">今日</a>
			<a class="fcbl " dataType="2" data='2013-06-02' href="#">本周</a>
			<a class="fcbl " dataType="3" data='2013-06-01' href="#">本月</a>
			<a class="fcbl " dataType="4" data='2013-01-01' href="#">本年</a>
		</div>
		<input id="startDate" name="startDate" type="text" value="${start }" class="middleInput left" defaultText="开始日期" onfocus="WdatePicker()" />
		<span class="left"> 至 </span> 
		<input id="endDate" name="endDate" type="text" value="${end }" class="middleInput left mlm" defaultText="结束日期" onfocus="WdatePicker()" />
		<input type="button" class="submitBtn left" value="" />
		<div class="clear"></div>
	</div>

	<!-- <div class="searchCondition" field="newsType">
		<span class="title">类型：</span> <a class="noDistrict fco fwb" href="#">不限</a>
		<div class="districtCodition">
			<a class="fcbl" data='本埠动态' href="#">本埠动态</a> 
			<a class="fcbl" data='城建规划' href="#">城建规划</a> 
			<a class="fcbl" data='房屋故事' href="#">房屋故事</a>
			<a class="fcbl" data='机构动态' href="#">机构动态</a> 
			<a class="fcbl" data='社会经济' href="#">社会经济</a>
			<a class="fcbl" data='新盘快讯' href="#">新盘快讯</a>
			<a class="fcbl" data='政策法规' href="#">政策法规</a>
		</div>
		<div class="clear"></div>
	</div> -->
	<div class="searchCondition" field="keywords">
		<span class="title">其他：</span>
		<input id="keywords" type="text" value="${keywords}" class="middleInput left" defaultText="新闻关键字" />
		<input type="button" class="submitBtn left" value="" field="keywords" />
		<div class="clear"></div>
	</div>

	<div class="pts">
		<div class="solidLine"></div>
		<p class="pvm">
			<b>当前搜索条件：</b> 
			<span id="currentCondition">
			<c:choose>
				<c:when test="${not empty dateTypeZW}">
					<b>时间：</b>
					<a field="dateType" title="移除此条件" class="closeBtnBlue fco mrm" href="#">
						${dateTypeZW }
					</a>
				</c:when>
				<c:otherwise>
					<c:if test="${not empty start or not empty end}">
						<b>时间：</b>
						<a field="date" title="移除此条件" class="closeBtnBlue fco mrm" href="#">
							<c:choose>
						 	<c:when test="${empty start}">不限</c:when>
							<c:otherwise>${start }</c:otherwise>
							</c:choose> 
							至
							<c:choose>
						 	<c:when test="${empty end}">不限</c:when>
							<c:otherwise>${end }</c:otherwise>
							</c:choose>
						</a>
					</c:if>
				</c:otherwise>
			</c:choose> 
			
			<c:if test="${not empty keywords}">
		    	<b>关键字：</b><a field="keywords" title="移除此条件" class="closeBtnBlue fco mrm" href="#">${keywords }</a>	
		    </c:if>		
			</span>
		</p>
	</div>
</div>

<div class="tabBtm tabBtmLar"></div>
</div>

<div class="tabTop"></div>
<ul class="tab">
	<li class="left">
		<a publishType='0' class="tabFirst" href="/News/">
			<span class="tabLeft"></span>
			<span class="tabCenter">新闻</span>
			<span class="tabRight"></span>
		</a>
	</li>
<!-- 	<li class="left"> -->
<!-- 		<a publishType='2' class="" href="/News/Comment"> -->
<!-- 			<span class="tabLeft"></span> <span class="tabCenter">评论</span> <span -->
<!-- 			class="tabRight"></span> -->
<!-- 	</a></li> -->
	<li class="clear"></li>

</ul>
<div class="clear"></div>
<div class="tabCont pvs">
	<div class="homepageHouseList">
		<c:choose>
	 	<c:when test="${empty list}">
	 		<div style="text-align: center;">没有新闻！</div>
		</c:when>
		<c:otherwise>
			<c:forEach var="item" items="${list}">  
			<ul class="houseList" onclick="window.open('<%=path %>/news/newscontent.do?nid=${item.Nid }');" title="点击查看新闻详情">
				
				<li class="houseListRight">
					<div class="clearfix fcb">
						<div>
							<a href="<%=path %>/news/newslist.do"   class="houseTitle">${item.TITLE }</a>
						</div>
						<div class="right mrm fcg">${item.DISPLAY_DATE }</div>
					<div class="clear"></div>
						<div>
							<p>${item.DISPLAY_CONTENT }</p>
						</div>
	
					</div>
				</li>
				<li class="clear"></li>
			</ul>
	 		</c:forEach>
	
			<jmu:pager totalPage="${totalPage }" currentPage="${currentPage }"></jmu:pager>
		</c:otherwise>
		</c:choose> 
		
	</div>
	<div class="clear"></div>
</div>
<div class="tabBtm"></div>
<script type="text/javascript">

        var newsType = '房屋故事';
        var keywords = '';
        var order = 'Id';
        var isAsc = false;
        var dateType = 0;
        // 新闻搜索
        function initSearchCondition2() {
            $(".submitBtn").bind("click", function () {
                var field = $(this).attr("field");
                if (field == 'keywords' && $("#keywords").val() != $("#keywords").attr("defaultText")) {
                    keywords = $("#keywords").val();
                }
                doSearchNews();
                return false;
            });
                // change style
            // 绑定点击事件
            $("#searchCondition2 div.searchCondition a").bind("click", function () {
                // change style
                
                $(this).parents(".searchCondition").find(".noDistrict").removeClass("fco").removeClass("fwb").addClass("fcbl");
                $(this).parents(".searchCondition").find("a").removeClass("fco").removeClass("fwb");
                $(this).addClass("fco").addClass("fwb");
                var field = $(this).parents(".searchCondition").attr("field");
                var data = $(this).attr("data");
                dateType = $(this).attr("dataType");
                if (field == 'date') {
                    $("#startDate").val(data);
                    $("#endDate").val('');
                }
                else if (field == 'newsType') {
                    newsType = data;
                }
                else if (field == 'keywords') {
                    keywords = $("#keywords").val();
                }
                doSearchNews();
                return false;
            });
            $("#HasPicture").change(function () {
                doSearchNews();
            });
            $("a.OrderLink").click(function () {
                var newOrder = $(this).attr('data');
                if (newOrder != order) {
                    order = newOrder;
                    isAsc = "";
                }
                else if (!isAsc) {
                    isAsc = "true";
                }
                else {
                    order = '';
                    isAsc = '';
                }
                doSearchNews();
            });

            $("a.closeBtnBlue").click(function(){
                if($(this).hasClass("deleteComment"))
                {
                    // 避免与评论的删除按钮冲突
                    return;
                }
                var field = $(this).attr("field");
                if(field == "date")
                {
                    $("#startDate").val("");
                    $("#endDate").val("");
                }
                else if(field == "dateType")
                {
                	 $("#startDate").val("");
                     $("#endDate").val("");
                }
                else if(field == "keywords")
                {
                    keywords = "";
                }
                
                doSearchNews();
                return false;
            });
        }

        function doSearchNews() {
            var url = '<%=path%>/news/newslist.do?r=search';
            
            if ($("#startDate").val() && $("#startDate").val() != $("#startDate").attr("defaultText")) {
                url += "&start=" + $("#startDate").val();
            }
            if ($("#endDate").val() && $("#endDate").val() != $("#endDate").attr("defaultText")) {
                url += "&end=" + $("#endDate").val();
            }
            if (dateType > 0) {
                url += "&dateType=" + dateType;
            }
            if (keywords) {
                url += "&keywords=" + encodeURI(encodeURI(keywords));
            }
            if ($("#HasPicture").attr("checked")) {
                url += "&hasPicture=true";
            }
            if (order && order != "Id") {
                url += "&order=" + order;
            }
            if (isAsc) {
                url += "&isAsc=" + isAsc;
            }
            window.location.href = url;
        }
        
        $(document).ready(function () {
            initSearchCondition2();           
        });
    </script>

<%@ include file="foot.jsp"%>
